/*
Copyright [2023] [fuwen_soft]
*/
package vip.xiaonuo.modular.xyrule.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.modular.xyrule.param.XyRuleParam;
import vip.xiaonuo.modular.xyrule.service.XyRuleService;
import vip.xiaonuo.modular.xyrule.entity.XyRule;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.core.annotion.version.AdminVersionSwagger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.List;
import vip.xiaonuo.sys.core.msg.Result;
import static vip.xiaonuo.sys.core.msg.ResultUtils.success;
/**
 * 规则动态配置表单控制器
 *
 * @author yanwei
 * @date 2023-05-05 17:45:21
 */
@RestController
@Api(tags = "后台管理 规则动态配置表单 相关APIS")
@AdminVersionSwagger
public class XyRuleController {

    @Resource
    private XyRuleService xyRuleService;

    /**
     * 查询规则动态配置表单
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @GetMapping("/xyRule/page")
    @BusinessLog(title = "规则动态配置表单_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("规则动态配置表单_查询")
    public Result<PageResult<XyRule>> page(XyRuleParam xyRuleParam) {
        PageResult<XyRule> page = xyRuleService.page(xyRuleParam);
        return success(page);
    }

    /**
     * 添加规则动态配置表单
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @PostMapping("/xyRule/add")
    @BusinessLog(title = "规则动态配置表单_增加", opType = LogAnnotionOpTypeEnum.ADD)
    @ApiOperation("规则动态配置表单_增加")
    public Result add(@RequestBody @Validated(XyRuleParam.add.class) XyRuleParam xyRuleParam) {
            xyRuleService.add(xyRuleParam);
        return success();
    }

    /**
     * 删除规则动态配置表单，可批量删除
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @PostMapping("/xyRule/delete")
    @BusinessLog(title = "规则动态配置表单_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    @ApiOperation("规则动态配置表单_删除")
    public Result delete(@RequestBody @Validated(XyRuleParam.delete.class) List<XyRuleParam> xyRuleParamList) {
            xyRuleService.delete(xyRuleParamList);
        return success();
    }

    /**
     * 编辑规则动态配置表单
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @PostMapping("/xyRule/edit")
    @BusinessLog(title = "规则动态配置表单_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    @ApiOperation("规则动态配置表单_编辑")
    public Result edit(@RequestBody @Validated(XyRuleParam.edit.class) XyRuleParam xyRuleParam) {
            xyRuleService.edit(xyRuleParam);
        return success();
    }

    /**
     * 查看规则动态配置表单
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @GetMapping("/xyRule/detail")
    @BusinessLog(title = "规则动态配置表单_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    @ApiOperation("规则动态配置表单_查看")
    public Result<XyRule> detail(@Validated(XyRuleParam.detail.class) XyRuleParam xyRuleParam) {
        XyRule detail =   xyRuleService.detail(xyRuleParam);
        return success(detail);
    }

    /**
     * 规则动态配置表单列表
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @GetMapping("/xyRule/list")
    @BusinessLog(title = "规则动态配置表单_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    @ApiOperation("规则动态配置表单_列表")
    public Result<List<XyRule>> list(XyRuleParam xyRuleParam) {
        List<XyRule> list  =   xyRuleService.list(xyRuleParam);
        return success(list);
    }

    /**
     * 导出系统用户
     *
     * @author yanwei
     * @date 2023-05-05 17:45:21
     */
    @Permission
    @GetMapping("/xyRule/export")
    @BusinessLog(title = "规则动态配置表单_导出", opType = LogAnnotionOpTypeEnum.EXPORT)
    @ApiOperation("规则动态配置表单_导出")
    public void export(XyRuleParam xyRuleParam) {
        xyRuleService.export(xyRuleParam);
    }

}
